import React, { useContext } from 'react';
import {useHistory} from 'react-router-dom';
import {Button} from 'reactstrap';

import {AuthContext} from '../auth-context';

const Home = () => {

  const {logout} = useContext(AuthContext);

  const history = useHistory();

  const handleLogout = (e) => {
    e.preventDefault();
    logout();
    history.push('/login');
  }

  return <div>
    <div> Yeppie! Long trip to reach here. This is THE home page.</div>
    <Button onClick={handleLogout}>Logout</Button>
  </div>
};

export default Home;